package com.lottery.system.common.config;
import com.lottery.system.common.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays;
import java.util.List;

/**
 * @author: xiaoxie
 * create: 2024-09-05 20:49
 * @BelongsProject: lottery-system
 * @BelongsPackage: com.lottery.system.common.config
 * description: 登录拦截器配置
 */
@Configuration
public class AppLoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;
    private final List<String> excludes = Arrays.asList(
            "/**/*.html",
            "/css/**",
            "/js/**",
            "/pic/**",
            "/image/**",
            "/*.jpg",
            "/*.png",
            "/favicon.ico",
            "/user/password/login",
            "/user/captcha/login/login",
            "/user/register",
            "/captcha/send",
            "/winning-records/show",
            "/user/captcha/send",
            "/winning-records/show"
    );
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludes);
    }
}
